﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _13.策略模式
{
    class Program
    {
        static void Main(string[] args)
        {
            Context PShow = new Context(new PersonStragety());
            Console.WriteLine("单人票单价为：{0}", PShow.GetTax(100.00));
            Context GShow = new Context(new Group());
            Console.WriteLine("团体票单价为：{0}", GShow.GetTax(100.00));

            Console.Read();

        }
    }
    public interface Stragety
    {
        double CalculateTax(double income);
    }
    public class PersonStragety : Stragety//单人票
    {
        public double CalculateTax(double income)
        {
            return income;
        }
    }
    public class Group : Stragety//团体票
    {
        public double CalculateTax(double income)
        {
            return income * 0.9f;
        }
    }
    public class Context
    {
        private Stragety m_stragety;
        public Context(Stragety stragety)
        {
            m_stragety = stragety;
        }
        public double GetTax(double income)
        {
            return m_stragety.CalculateTax(income);
        }
    }
 
}
